<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>互调宿舍</title>
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/apartmentViewAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/studentLodgeMgrAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type='text/javascript'
			src="<%=request.getContextPath()%>/js/tabcard.js"></script>
			<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>
		<script type='text/javascript'>
var stuno_bs_1;   //bs = basic student.  学号
var studentdormitorytype = -1;//与dormitoryconcretefuncid对应,宿舍具体功能代码

//属于tabcard.js里的方法，在单击tab时触发
function mSearch_1(obj){
	if(stuno_bs_1 != null){
		switch(obj.id){
			case "basicInfo_bs_1" : studentAction.getStudentBasicInfo(stuno_bs_1,studentdormitorytype,stu_BasicInfoCallback_1);break;
			case "dormHistory_bs_1" : studentAction.getStudentHistoryAccomodationInfo(stuno_bs_1,studentdormitorytype,stu_HistoryAccomodationInfoCallback_1);break;
			case "chargeInfo_bs_1" : studentAction.getStudentChargeRecord(stuno_bs_1,studentdormitorytype,getStudentChargeRecordCallback_1);break;
			case "dormRate_bs_1": searchDormitoryRateStatus_1();break;
		}
	}
	
}
//验证输入是否有效
function validate_bs_1(){
	stuno_bs_1 = strTrim_cv($('student_info_1').value);
	if(stuno_bs_1 == ""){
			alert("请输入学号！");
			return false;
	}
	if(!cnChar_cv(stuno_bs_1)){
			alert("您只能输入数字,字母和汉字,请重新输入");
			return false;
	}
	return true;
}
//搜索学生信息
//对外的接口方法
function stu_BasicInfo_1(){
	
	var b = validate_bs_1();
	if(false == b){
		return ;
	}
	//mSearch()本是tabcard.js中调用的方法,这里调用它,判断当前激活的tab,并触发相关的方法
	mSearch_1($j('.active').get(1))
	
}
var stu_BasicInfoCallback_1 = function stu_BasicInfoCallbackFunc(stulist_1){
	if(stulist_1 == null){
		alert("没有该学生的信息");
		return;
	}
	var slist = stulist_1;
	if($('studentno_1') != null){
		$('studentno_1').value = slist[1];
	}
	$('student_id_1').innerHTML = slist[0]; //给学生的id赋值	
	$('stuNo_1').innerHTML = slist[1];
	$('stuName_1').innerHTML = slist[2];
	$('stuGender_1').innerHTML = slist[3];
	$('stuCollege_1').innerHTML = slist[4];
	$('stuMajor_1').innerHTML = slist[5];
	$('stuClass_1').innerHTML = slist[6];
	$('stuDorm_1').innerHTML = slist[7];
	$('stuPhone_1').innerHTML = slist[8];
	$('studentpicture_1').src="/dms"+slist[9];
	$('stuEthnic_1').innerHTML = slist[10];
	$('stuBirthplace_1').innerHTML = slist[11];
	$('stuBirthday_1').innerHTML = slist[12];
	$('stuType_1').innerHTML = slist[13];
}
//返回的historyAccomodationRecordList是二维数组
var stu_HistoryAccomodationInfoCallback_1=function stu_HistoryAccomodationInfoCallbackFunc(historyAccomodationRecordList){
	//删除为查询历史住宿信息生成的动态表格
	for(var i=$('student_accomodation_history_1').rows.length-1;i>0;i--){ 
       	$('student_accomodation_history_1').deleteRow(i); 
   	} 
	
   	
   	//判断历史住宿信息是否为空
   	if(null == historyAccomodationRecordList){
   		return;
   	}
   	//动态添加新的记录行
   	var oneHistoryAccomodationRecord;
   	//alert(historyAccomodationRecordList);
   	//oneHistoryAccomodationRecord =  eval('('+historyAccomodationRecordList+')');
	for(var n=0;n<historyAccomodationRecordList.length;n++){
		oneHistoryAccomodationRecord = historyAccomodationRecordList[n];
		myrow=$("student_accomodation_history_1").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=oneHistoryAccomodationRecord[2];
		c=myrow.insertCell(1);
		c.innerHTML=oneHistoryAccomodationRecord[0];
		c=myrow.insertCell(2);
		c.innerHTML=oneHistoryAccomodationRecord[1];
	}
}

var getStudentChargeRecordCallback_1 = function getStudentChargeRecordCallbackFunc_1(list){
	//删除为查询历史交费生成的动态表格
	
	for(var i=$('student_charge_history_1').rows.length-1;i>0;i--){ 
       	$('student_charge_history_1').deleteRow(i); 
   	} 
	
   	//动态添加新的记录行
   	var oneHistoryChargeRecord;
   	
   	if(null == list){
   		return;
   	}
   	//alert(historyAccomodationRecordList);
   	//oneHistoryAccomodationRecord =  eval('('+historyAccomodationRecordList+')');
	for(var n=0;n<list.length;n++){
		oneHistoryChargeRecord = list[n];
		myrow=$("student_charge_history_1").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=oneHistoryChargeRecord[2];
		c=myrow.insertCell(1);
		c.innerHTML=(oneHistoryChargeRecord[4]==1)?"已交费":"未交费";
		c=myrow.insertCell(2);
		c.innerHTML=oneHistoryChargeRecord[3];
	}
}


function searchDormitoryRateStatus_1(){
	if(stuno_bs_1 != null && stuno_bs_1 != ""){
		dormitoryStatusViewAction.getDormitoryRateStatus(stuno_bs_1,studentdormitorytype,searchDormitoryRateStatusCallback_1);
	}
}
var searchDormitoryRateStatusCallback_1 = function searchDormitoryRateStatusCallbackFunc(list){
	//删除为查询宿舍卫生状况生成的动态表格
	//表格有一个头部,所以第一行不删
	for(var i=$('student_dorm_hygienic_1').rows.length-1;i>0;i--){ 
       	$('student_dorm_hygienic_1').deleteRow(i); 
   	} 
   	//判断宿舍卫生状况记录是否为空
   	if(null == list){
   		return;
   	}
	for(var n=0;n<list.length;n++){
		l = list[n];
		//表格有一个头部,所以后面插入的行号要加一
		myrow=$("student_dorm_hygienic_1").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=l[3];
		c=myrow.insertCell(1);
		c.innerHTML=l[2];
		c=myrow.insertCell(2);
		c.innerHTML=l[4];
	}
}	


function submitExchange(){

var studentidno = $("student_id").innerHTML;
var studentidno_1 = $("student_id_1").innerHTML;
if(studentidno==studentidno_1){
	alert("同一个学生不可以互换宿舍哦！");
	return;
}
studentLodgeMgrAction.swapStudents(studentidno,studentidno_1,submitcallback);
}
var submitcallback = function setMsg(statusMsg){
		alert(statusMsg);
}
</script>
	<body>
		<div id="page_container">
			<%@include file="changebanner.jsp"%>
			<h2>
				交换宿舍
			</h2>
			<!-- 引入学生基本信息页面 -->
			<jsp:include page="/allperson/basicstudentinfo.jsp"></jsp:include>
	
			<div id="student_basic_info_1">
				<div id="student_basic_info_search_1">
					请输入编号(学号,工作号,临时编号等)：
					<input name="textfield" type="text" id="student_info_1" onfocus="stuno_button_onfocus_func_bs()" onblur="stuno_button_onblur_func_bs()"/>
					<input class="common_button" type="submit" name="button" id="button" value="搜索"
						onclick="stu_BasicInfo_1()" />
				</div>
				<div class="tab_card" id="student_basic_info_tab_1">
					<ul class="menu">
						<li class="active" id="basicInfo_bs_1">
							基本信息
						</li>
						<li id="dormHistory_bs_1">
							住宿历史
						</li>
						<li id="chargeInfo_bs_1">
							交费信息
						</li>
						<li id="dormRate_bs_1">
							卫生评比
						</li>
					</ul>
					<div class="tab_card_con">
						<div id="student_basic_cont2">
							<table class="table_student_basic_info">
								<tbody>
									<tr>
										<td rowspan="7">
											<img id="studentpicture_1"
												src="<%=request.getContextPath()%>/images/nobody.jpg"
												width="90px" height="120px" alt="头像" />
										</td>
										<td class="st_td_left">
											学号
										</td>
										<td class="st_td_right_1">
											<div id="stuNo_1"></div>
										</td>
										<td class="st_td_left">
											学院
										</td>
										<td class="st_td_right">
											<div id="stuCollege_1"></div>
										</td>
									</tr>
									<tr>
										<td class="st_td_left">
											姓名
										</td>
										<td class="st_td_right_1">
											<div id="stuName_1"></div>
										</td>
										<td class="st_td_left">
											专业
										</td>
										<td class="st_td_right">
											<div id="stuMajor_1"></div>
										</td>
									</tr>
									<tr>
										<td class="st_td_left">
											性别
										</td>
										<td class="st_td_right_1">
											<div id="stuGender_1"></div>
										</td>
										<td class="st_td_left">
											班级
										</td>
										<td class="st_td_right">
											<div id="stuClass_1"></div>
										</td>
									</tr>
									<tr>
										<td class="st_td_left">
											民族
										</td>
										<td class="st_td_right_1">
											<div id="stuEthnic_1"></div>
										</td>
										<td class="st_td_left">
											类别
										</td>
										<td class="st_td_right">
											<div id="stuType_1"></div>
										</td>
									</tr>
									<tr>
										<td class="st_td_left">
											籍贯
										</td>
										<td class="st_td_right_1">
											<div id="stuBirthplace_1"></div>
										</td>
										<td class="st_td_left">
											宿舍
										</td>
										<td class="st_td_right">
											<div id="stuDorm_1"></div>
										</td>
									</tr>
									<tr>
										<td class="st_td_left">
											生日
										</td>
										<td class="st_td_right_1">
											<div id="stuBirthday_1"></div>
										</td>
										<td class="st_td_left">
											手机
										</td>
										<td class="st_td_right">
											<div id="stuPhone_1"></div>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div id="student_basic_cont3">
							<table id="student_accomodation_history_1"
								class="table_student_basic_info">
								<tr>
									<td>
										宿舍号
									</td>
									<td>
										开始入住时间
									</td>
									<td>
										结束入住时间
									</td>
								</tr>
							</table>
						</div>
						<div id="student_basic_cont4">
							<table id="student_charge_history_1"
								class="table_student_basic_info">
								<tr>
									<td>
										交费时间
									</td>
									<td>
										交费状态
									</td>
									<td>
										交费金额
									</td>
								</tr>
							</table>
						</div>
						<div id="student_basic_cont5">
							<table id="student_dorm_hygienic_1"
								class="table_student_basic_info">
								<tr>
									<td>
										评分时间
									</td>
									<td>
										分数
									</td>
									<td>
										评分人
									</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
			<!-- 放学生的id的隐藏页 -->
			<div style="display: none" id="student_id_1" /></div>
			<!-- 双人调换学生查询结果显示结束 -->
			<div align="center">
				<input class="common_button" type="submit" value=对调宿舍
					onclick="javascript:submitExchange()" />
			</div>
		</div>
		<br />
		<script language="javascript">
	         //解除basicsudentinfo.jsp里的enter键事件,firefox下还有问题
			 $j(function(){
			 		$j(document).unbind("keydown",subEv);
			 })
            /**
             *
             * @param string tabId			当前标签组id
             * @param string fromContendId	要加载的内容的id前缀
             * @param int bindType	绑定方式 0为绑定鼠标移上效果 1为鼠标点击的效果
             * @version 1.0.0
             */
            //TabCard(tabId,fromContendId,bindType)
            var tmpObj = new TabCard("student_basic_info_tab_1", "student_basic_cont", 1);
            tmpObj.mActiveClass = "active";
            tmpObj.mNoActiveClass = "default";
            tmpObj.mListStartNumb = 2;
            tmpObj.initab();
            
			window.onload = function(){
				var nav_a=$j('#page_nav a');
				var nav_span=$j("#page_nav a span");
				for(var u = 0 ;u<nav_a.length;u++){
						nav_a.get(u).style.backgroundPosition="left top";
						nav_span.get(u).style.backgroundPosition="right top";							
				}
				$j('#page_nav a').get(0).style.backgroundPosition="0% -42px";
				$j("#page_nav a span").get(0).style.backgroundPosition="100% -42px";
			}	
</script>
	</body>
</html>